package com.example.zhangwei.ui;

import java.util.HashMap;

import com.example.zhangwei.Constants;
import com.example.zhangwei.R;
import com.example.zhangwei.model.DataParcelable;
import com.example.zhangwei.ui.activityfragment.MyFragmentActivity;
import com.example.zhangwei.ui.bindservice.BindActivity;
import com.example.zhangwei.ui.customview.CustomViewActivity;
import com.example.zhangwei.ui.demo.ActivityLiving;
import com.example.zhangwei.ui.drawview.DrawMoveLineLayout;
import com.example.zhangwei.ui.gallery3d.GalleryActivity;
import com.example.zhangwei.ui.photoselect.PhotoSelectImageView;
import com.example.zhangwei.ui.refreshlist.RefreshListActivity;
import com.example.zhangwei.ui.tabactivityfragment.MyTabActivity;
import com.example.zhangwei.ui.treelist.TreeListActivity;
import com.example.zhangwei.ui.triangle.TriangleLayout;
import com.example.zhangwei.ui.viewpagerfragment.ViewPagerFragment;
import com.example.zhangwei.util.BaseActivity;
import com.example.zhangwei.util.MyLogger;
import com.example.zhangwei.util.UtilMethod;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends BaseActivity {
	
	private ListView mMainListView ; 
	
	private MyLogger log = MyLogger.getLogger("MainActivity");

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		log.e("----------MainActivity_onCreate-----------");
		String[] listViewValue = getResources().getStringArray(R.array.main_listview_value);
		
		mMainListView = (ListView) findViewById(R.id.main_listview);
		mMainListView.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, listViewValue));
        
		mMainListView.setOnItemClickListener(new mOnItemClickListener());
	}
	
	
	class mOnItemClickListener implements OnItemClickListener{

		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) 
		{
			switch(arg2)
			{	        	
			case 0:
				//Parcelable传递 复杂类
				Bundle bd = new Bundle(); 
				DataParcelable data= new DataParcelable();
				data.id = 1;
				data.name = "zhangwei";
				data.mapData = new HashMap<String, String>();
				data.mapData.put("map", "mapget");
				bd.putParcelable(Constants.PassDataKey.PARCELABLE, data);
				changeTo(ActivityLiving.class,bd);
				break;
			case 1:
				changeTo(BindActivity.class);
				break;
			case 2:
				changeTo(CustomViewActivity.class);				
				break;
			case 3:
				changeTo(GalleryActivity.class);				
				break;
			case 4:
				changeTo(RefreshListActivity.class);				
				break;
			case 5:
				changeTo(TreeListActivity.class);				
				break;
			case 6:
				changeTo(ViewPagerFragment.class);			
				break;
			case 7:
				changeTo(MyFragmentActivity.class);			
				break;
			case 8:
				changeTo(MyTabActivity.class);			
				break;
			case 9:
				changeTo(DrawMoveLineLayout.class);			
				break;
			case 10:
				changeTo(PhotoSelectImageView.class);			
				break;
			case 11:
				changeTo(TriangleLayout.class);			
				break;
			default:
				break;
			}
		}
	}
	
    @Override
    public void onBackPressed() {
    	// TODO Auto-generated method stub
    	UtilMethod.getInstance().showDialogBack(this);
//    	super.onBackPressed();    	
    }

//	@Override
//	public boolean onCreateOptionsMenu(Menu menu) {
//		// Inflate the menu; this adds items to the action bar if it is present.
//		getMenuInflater().inflate(R.menu.main, menu);
//		return true;
//	}

}
